package com.yogee.topseller.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yogee.topseller.R;
import com.yogee.topseller.activity.PayActivity;
import com.yogee.topseller.activity.ZxActivity;
import com.yogee.topseller.bean.QyfxBean;
import com.yogee.topseller.bean.XwzxBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 企业风险
 * @auathor ${XiaoJianghong}
 * @date 2017/6/26.
 */

public class QyfxAdapter extends RecyclerView.Adapter<QyfxAdapter.ItemHolder> {

    private Context context;
    private List<QyfxBean.External> beans = new ArrayList<>();


    private PayActivity.Listener listener;

    public QyfxAdapter(Context context) {
        this.context = context;
    }

    public void addData(List<QyfxBean.External> beans) {
        this.beans = beans;
        notifyDataSetChanged();
    }

    public void setListener(PayActivity.Listener listener){
        this.listener = listener;
    }

    @Override
    public ItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_xzcf_item1, parent, false);
        return new ItemHolder(view);
    }

    @Override
    public void onBindViewHolder(ItemHolder holder, final int position) {
        if(position==0)
            holder.view_line.setVisibility(View.GONE);
        else
            holder.view_line.setVisibility(View.VISIBLE);
        final QyfxBean.External bean = beans.get(position);
        holder.tv_title.setText(Html.fromHtml(bean.getTitle()));
        holder.tv_laiyuan.setText("类型:"+bean.getDesc());
        holder.tv_time.setText("数量:"+bean.getRiskCount());
    }

    private String getTypeName(int type){
        switch (type){
            case 1:
                return "严重违法";
            case 2:
                return "失信人";
            case 3:
                return "失信公司";
            case 4:
                return "被执行人";
            case 5:
                return "被执行公司";
            case 6:
                return "行政处罚";
            case 7:
                return "经营异常";
            case 8:
                return "法律诉讼";
            case 9:
                return "股权出质";
            case 10:
                return "动产抵押";
            case 11:
                return "欠税公告";
            case 12:
                return "名称变更";
            case 13:
                return "开庭公告";
            case 14:
                return "法院公告";
            case 15:
                return "法人变更";
            case 16:
                return "投资人变更";
            case 17:
                return "主要人员变更";
            case 18:
                return "注册资本变更";
            case 19:
                return "注册地址变更";
            case 20:
                return "出资情况变更";
            default:
                return "严重违法";
        }
    }

    @Override
    public int getItemCount() {
        return beans == null ? 0 : beans.size();
    }

    class ItemHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.view_line)
        View view_line;
        @BindView(R.id.tv_title)
        TextView tv_title;
        @BindView(R.id.tv_laiyuan)
        TextView tv_laiyuan;
        @BindView(R.id.tv_time)
        TextView tv_time;

        public ItemHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }


}